package com.controller.yxy;
import com.alibaba.fastjson2.JSONArray;
import com.alibaba.fastjson2.JSONObject;
import com.bean.yxy.Yxy3;
import com.bean.yxy.Yxy4;
import com.service.yxyService.GetDataService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.List;

/**
 * 收费管理-2抄表录入
 */
@Controller
@RequestMapping("/YXYpage/")
public class TranscribeController {
    @Resource
    private GetDataService  getDataService;
    /**2
     * 加载下拉框
     * @return
     */
    @RequestMapping(value = "getselect101",method = RequestMethod.GET)
    @ResponseBody
    public Object getselect101(){
        return getDataService.getselect101();
    }

    /**2
     * 获取总数居
     * @return
     */
    @RequestMapping(value = "selectAllbiao",method = RequestMethod.GET)
    @ResponseBody
    public Object selectAllbiao(){
        return getDataService.selectAllbiao();
    }

    /**2
     * 点击查询
     * @return
     */
    @RequestMapping(value = "selecttiaojianchaxun",method = RequestMethod.GET)
    @ResponseBody
    public Object selecttiaojianchaxun(String tid,String text){
        return getDataService.selecttiaojianchaxun(tid,text);
    }

    /**2
     * 删除数据
     * @param chid
     * @return
     */
    @RequestMapping(value = "delectchid",method = RequestMethod.POST)
    @ResponseBody
    public Object delectchid(String chid){
        return getDataService.delectchid(chid);
    }


    /**2
     * 删除数据多个
     * @param
     * @return
     */
    @RequestMapping(value = "delectchids",method = RequestMethod.POST)
    @ResponseBody
    public Object delectchids(HttpServletRequest request){
       Object[] arr =  request.getParameterValues("arr[]");
        return getDataService.delectchids(arr);
    }

    /**
     * 修改数据
     * @param did 缴费明细表id
     * @param
     * @return
     */
    @RequestMapping(value = "xiugaimingxibiaoone",method = RequestMethod.POST)
    @ResponseBody
    public Object xiugaimingxibiaoone(String did,String zl){
        return getDataService.xiugaimingxibiaoone(did,zl);
    }

    /**2
     * 手工添加数据
     * @return
     */
    @RequestMapping(value = "addzhangdanmingxi",method = RequestMethod.POST)
    @ResponseBody
    public Object addzhangdanmingxi(Yxy3 y){
        return getDataService.addzhangdanmingxi(y);
    }

    /**2
     * 录入excel添加数据
     * @return
     */
    @RequestMapping(value = "daoruexcel",method = RequestMethod.POST)
    @ResponseBody
    public Object daoruexcel(String xsl){
        JSONArray arr= JSONArray.parseArray(xsl);
        List<Yxy4> l =arr.toList(Yxy4.class);
        int size = l.size();
        int i = 0;
        for(Yxy4  a:l){
            Yxy3 o =getDataService.getids(a);
            boolean b=(boolean)getDataService.addzhangdanmingxi(o);
            if(b){
                i++;
            }
        }
        if(size==i){
            return true;
        }else {
            return false;
        }
    }


    /**2
     * 加载小区下拉框
     * @return
     */
    @RequestMapping(value = "xiaoqulist1",method = RequestMethod.GET)
    @ResponseBody
    public Object xiaoqulist1(){
        return getDataService.xiaoqulist1();
    }

    /**2
     * 小区-->楼宇
     */
    @RequestMapping(value = "getlouyulist",method = RequestMethod.GET)
    @ResponseBody
    public Object getlouyulist(String id){
        return getDataService.getlouyulist(id);
    }

    /**2
     * 楼宇-->单元
     */
    @RequestMapping(value = "getdanyuanlist",method = RequestMethod.GET)
    @ResponseBody
    public Object getdanyuanlist(String id){
        return getDataService.getdanyuanlist(id);
    }

    /**2
     * 单元-->房间号
     */
    @RequestMapping(value = "getfanghaolist",method = RequestMethod.GET)
    @ResponseBody
    public Object getfanghaolist(String id){
        return getDataService.getfanghaolist(id);
    }

    /**2
     * 根据小区变换显示项目相关信息
     */
    @RequestMapping(value = "addxiangmulist1",method = RequestMethod.POST)
    @ResponseBody
    public Object addxiangmulist1(String vid){
        return getDataService.addxiangmulist1(vid);
    }
}
